<%@page import="java.util.Date"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html lang="ko">
<head>
	<%@ include file="/include/header.jsp" %>
	<link rel="stylesheet" href="<%=cp %>/css/board.css">
	<link rel="stylesheet" href="<%=cp %>/css/default.css">
	<%@ include file="/include/commonRes.jsp" %>
	<script type="text/javascript">
		$(function(){
			
			$("#bo_cate_ul li a").click(function(){
				var idstr=$(this).attr("id");
				if(idstr=="dept_my") {
					$("#tabList input[name='listMode']").val("person");
				} else if(idstr=="dept_sawon") {
					$("#tabList input[name='listMode']").val("sawon");
				} else if(idstr=="dept_team1") {
					$("#tabList input[name='listMode']").val("team1");
					$("#tabList input[name='listMode']").val("team1");
					
				} else if(idstr=="dept_team2") {
					$("#tabList input[name='listMode']").val("team2");
					$("#tabList input[name='mb_dept_code']").val("1");
					$("#tabList input[name='mb_team_code']").val("2");
				} else if(idstr=="dept_team3") {
					$("#tabList input[name='listMode']").val("team3");
					$("#tabList input[name='mb_dept_code']").val("2");
					$("#tabList input[name='mb_team_code']").val("1");
				} else if(idstr=="dept_dept1") {
					$("#tabList input[name='listMode']").val("dept1");
					$("#tabList input[name='mb_dept_code']").val("1");
				} else if(idstr=="dept_dept2") {
					$("#tabList input[name='listMode']").val("dept2");
					$("#tabList input[name='mb_dept_code']").val("2");
				} else if(idstr=="dept_wonjang") {
					$("#tabList input[name='listMode']").val("wonjang");
					$("#tabList input[name='mb_dept_code']").val("3");
				} else if(idstr=="dept_deptjang") {
					$("#tabList input[name='listMode']").val("deptjang");
					$("#tabList input[name='mb_dept_code']").val("4");
				}
				
				<c:if test="${sessionScope.ss_mb.mb_auth_code ==2}">
				$("#tabList input[name='mb_team_code']").val("${sessionScope.ss_mb.mb_team_code}");
				</c:if>
				
				$("#tabList").submit();
				return false;
			});
			
			
			$("#btn_regEdit").click(function(){
				editForm();
				return false;
			});
		});
		function view(mb_id,paramDay){
			$("#viewForm input[name='mb_id']").val(mb_id);
			$("#viewForm input[name='paramDay']").val(paramDay);
			$("#viewForm").submit();
			return false;
		}
		
		function editForm(){
			//var mb_id=$("#editForm input[name='mb_id']").val();
			//var paramDay=$("#editForm input[name='paramDay']").val();
			//var paramData={"mb_id":mb_id,"paramDay":paramDay};
			
			<%-- var success=function(data){
				if(data=="0000"){
					alert("이미 작성된 TeamTouch입니다.");
					return false;
				} else{
					$("#editForm").submit();
				}
			}
			var error=function(xhr,error,response){
				alert("시스템 오류입니다. 다시 시도해주세요.");
				return false;
			}
			var dataType="html";
			var type="POST";
			var url="<%=cp%>/teamt/teamt_answer_chk.do";
			sendAjax(type,dataType,url,paramData,success,error); --%>
			$("#editForm").submit();
			return false;
		}
		
		function search(){
			var sYear = $("#fsearch select[name='sYear'] option:selected");
			var sMonth = $("#fsearch select[name='sMonth'] option:selected");
			
			var sYear_val = sYear.val();
			var sMonth_val = sMonth.val();
						
			if(sMonth_val!=null && sMonth_val!="" && (sYear_val==null || sYear_val=="")) {
				alert("월이 선택되었을시 년도를 선택하셔야 합니다.");
				return false;
			} 
			return true;
		}
	</script>
</head>
<body>
	<div id="hd_login_msg">최고관리자 최고관리자님 로그인 중 <a href="http://mkis.fieram.gethompy.com/bbs/logout.php">로그아웃</a></div>
	<%@include file="/include/mainMenuHeader.jsp" %>
	<div id="wrapper">
	  	<div style="margin-bottom:10px;margin-right:10px;">
			<div style="width:80%;float:left;">
				<c:if test="${sessionScope.ss_mb.mb_auth_code ==1 || sessionScope.ss_mb.mb_auth_code ==6 }">
					<h2>나의 Teamtouch</h2>
				</c:if>
				<c:if test="${sessionScope.ss_mb.mb_auth_code !=1 && sessionScope.ss_mb.mb_auth_code !=6 }">
					<nav id="bo_cate2">
						<ul id="bo_cate_ul">
							<c:if test="${sessionScope.ss_mb.mb_auth_code !=7 && sessionScope.ss_mb.mb_auth_code !=8 }">
								<li>
									<a href="#" id="dept_my"  <c:if test="${listMode=='person' }">class="blackBold"</c:if>><span>나의</span><span>Teamtouch</span></a>
								</li>
							</c:if>
							<c:if test="${sessionScope.ss_mb.mb_auth_code ==2}">
								<li>
									<a href="#" id="dept_sawon" <c:if test="${listMode=='sawon' }">class="blackBold"</c:if>><span>팀원</span><span>Teamtouch</span></a>
								</li>	
							</c:if>
							<c:if test="${sessionScope.ss_mb.mb_auth_code ==3}">
								<c:if test="${sessionScope.ss_mb.mb_dept_code ==1}">
									<li>
										<a href="#" id="dept_team2" <c:if test="${listMode=='team2' }">class="blackBold"</c:if>><span>검안팀</span><span>Teamtouch</span></a>
									</li>
									<li>
										<a href="#" id="dept_team1" <c:if test="${listMode=='team1' }">class="blackBold"</c:if>><span>데스크팀</span><span>Teamtouch</span></a>
									</li>
								</c:if>
								<c:if test="${sessionScope.ss_mb.mb_dept_code ==2}">
									<li>
										<a href="#" id="dept_team3" <c:if test="${listMode=='team3' }">class="blackBold"</c:if>><span>진료팀</span><span>Teamtouch</span></a>
									</li>
								</c:if>
							</c:if>
							<c:if test="${sessionScope.ss_mb.mb_auth_code ==7|| sessionScope.ss_mb.mb_auth_code ==8}">
								<li>
									<a href="#" id="dept_wonjang" <c:if test="${listMode=='wonjang'}">class="blackBold"</c:if>><span>원장 </span><span>Teamtouch</span></a>
								</li>
								<li>
									<a href="#" id="dept_deptjang" <c:if test="${listMode=='deptjang'}">class="blackBold"</c:if>><span>차장/부장</span><span>Teamtouch</span></a>
								</li>
							</c:if>
							<c:if test="${sessionScope.ss_mb.mb_auth_code ==4 || sessionScope.ss_mb.mb_auth_code ==5 || sessionScope.ss_mb.mb_auth_code ==7|| sessionScope.ss_mb.mb_auth_code ==8}">
								<li>
									<a href="#" id="dept_dept1" <c:if test="${listMode=='dept1'}">class="blackBold"</c:if>>서비스1과  Teamtouch</a>
								</li>
								<li>
									<a href="#" id="dept_dept2" <c:if test="${listMode=='dept2'}">class="blackBold"</c:if>>서비스2과  Teamtouch</a>
								</li>
							</c:if>			
						</ul>
					</nav>
				</c:if>
			</div>
			<c:if test="${sessionScope.ss_mb.mb_auth_code !=8}">
				<div style="width:20%;float:left;">
					<form id="editForm" name="editForm" action="<%=cp%>/teamt/teamt_edit.do" method="get">
						<input type="hidden" name="mb_id" value="${sessionScope.ss_mb.mb_id }"/>	
						<input type="hidden" name="paramDay" value="<%=new SimpleDateFormat("yyyy-MM-dd").format(new Date(System.currentTimeMillis()))%>"/>
						<button type="button"  class="btn_gray btn_TT"  id="btn_regEdit"><span>Teamtouch</span><span>${modeText }</span></button>
				    </form>		
				</div>	 
			</c:if>
		</div> 
		<div class="bo_fx" style="clear:both;">	    
			<!-- list -->
			<div class="tbl_head01 tbl_wrap">
				<div class="notice_li_table">
					<ul class="subject th">
						<li class="num_area">번호</li>
						<li class="title_area2">제목</li>
						<li class="date_area">작성자</li>
					</ul>
					<c:if test="${totalcnt==0 }">
						<ul class="content">
							<li class="emptyList">목록이 없습니다.</li>					
						</ul>
					</c:if>
					<c:if test="${totalcnt!=0 }">
						<c:forEach var="item" items="${list }">
							<ul class="content">
								<li class="col font11 num_area">${item.row }</li>								
								<li class="font11 title_area2">
									<a href="#" onclick="view('${item.mb_id }','${item.teamtTouchDay }');"> 
										<span class="fontBold">[${item.teamtTouchDay }]</span>&nbsp;Teamtouch
									</a>
								</li>	
								<li class="font11 date_area">${item.regName }</li>
							</ul>
						</c:forEach>
					</c:if>
				</div>
			</div>
		</div>
		<div style="text-align: center;">
			<!-- 검색조건 -->
			<fieldset id="bo_sch">	
			 	<form id="pageFrm" name="pageFrm" method="post">
			 		<input type="hidden" name="mb_team_code" value="${sessionScope.ss_mb.mb_team_code }"/>
			 		<input type="hidden" name="listMode" value="${listMode }"/>
					<input type="hidden" name="page" value="${page }" >
					<input type="hidden" name="sYear" value="${sYear }" >
					<input type="hidden" name="sMonth" value="${sMonth }" >
					<input type="hidden" name="typeSelect" value="${typeSelect }">
					<input type="hidden" name="input"   value="${input }">
					<input type="hidden" name="mb_dept_code" value="${mb_dept_code }"/>
					<input type="hidden" name="mb_team_code" value="${mb_team_code }"/>
				</form>
				<legend>게시물 검색</legend>
				<form id="fsearch"  name="fsearch" method="post" onsubmit="return search();">
					<div class="list_search">
						<input type="hidden" name="listMode" value="${listMode }"/>
						<input type="hidden" name="mb_team_code" value="${sessionScope.ss_mb.mb_team_code }"/>
						<!-- 날짜검색조건 -->
						<span class="search_date">
							<select name="sYear">
								<option value="">년도</option>
								<c:forEach var="i" begin="2015" end="${endYear }" step="1">
								<c:if test="${sYear==i }">
									<option value="${i }" selected>${i }</option>	
								</c:if>
								<c:if test="${sYear!=i }">
									<option value="${i }">${i }</option>	
								</c:if>
								</c:forEach>
							</select>
							<select name="sMonth">
								<option value="">월</option>
								<c:forEach var="j" begin="01" end="12" step="1">
									<c:if test="${sMonth==j }">
										<option value="${j }" selected>${j }</option>	
									</c:if>
									<c:if test="${sMonth!=j }">
										<option value="${j }">${j }</option>	
									</c:if>
								</c:forEach>
							</select>
						</span>
						<!-- 제목/이름검색조건 -->
						<span>
							<label for="sfl" class="sound_only">검색대상</label>
							<input name="input" value="" placeholder="검색어(필수)" id="input" class="frm_input" size="15" maxlength="15">
							<input type="submit" value="검색" class="btn_submit">	
						</span> 				   
					</div>   
				</form>
			</fieldset>
			<form id="tabList" name="tabList" method="post">
				<input type="hidden" name="listMode" value="${listMode }"/>
				<input type="hidden" name="mb_dept_code" value=""/>
				<input type="hidden" name="mb_team_code" value=""/>
			</form>
			
			<form id="viewForm" name="viewForm" action="<%=cp %>/teamt/teamt_view.do" method="post">
				<input type="hidden" name="mb_id" value=""/>
				<input type="hidden" name="paramDay" value=""/>
				<input type="hidden" name="listMode" value="${listMode }"/>
				<input type="hidden" name="page" value="${page }" >
				<input type="hidden" name="sYear" value="${sYear }" >
				<input type="hidden" name="sMonth" value="${sMonth }" >
				<input type="hidden" name="typeSelect" value="${typeSelect }">
				<input type="hidden" name="input"   value="${input }">
			</form>
		</div>
		<%@ include file="/include/pageInc.jsp"%>
	</div>
	<%@ include file="/include/footer.jsp" %>
</body>
</html>